import request from "@/utils/request";
import type { AxiosPromise } from "axios";
import type {
  ContentCommentVO,
  ContentCommentForm,
  ContentCommentQuery,
} from "@/api/contentComment/types";

/**
 * 查询统一内容评论列表
 * @param query
 * @returns {*}
 */

export const listContentComment = (
  query?: ContentCommentQuery
): AxiosPromise<ContentCommentVO[]> => {
  return request({
    url: "/business/contentComment/list",
    method: "get",
    params: query,
  });
};

/**
 * 查询统一内容评论详细
 * @param id
 */
export const getContentComment = (
  id: string | number
): AxiosPromise<ContentCommentVO> => {
  return request({
    url: "/business/contentComment/" + id,
    method: "get",
  });
};

/**
 * 新增统一内容评论
 * @param data
 */
export const addContentComment = (data: ContentCommentForm) => {
  return request({
    url: "/business/contentComment",
    method: "post",
    data: data,
  });
};

/**
 * 修改统一内容评论
 * @param data
 */
export const updateContentComment = (data: ContentCommentForm) => {
  return request({
    url: "/business/contentComment",
    method: "put",
    data: data,
  });
};

/**
 * 删除统一内容评论
 * @param id
 */
export const delContentComment = (
  id: string | number | Array<string | number>
) => {
  return request({
    url: "/business/contentComment/" + id,
    method: "delete",
  });
};

/**
 * 点赞或取消
 * @param data
 */
export const likeCountApi = (data: ContentCommentForm) => {
  return request({
    url: "/business/contentComment/likeCount",
    method: "post",
    data: data,
  });
};
